<?php
/*------------------------------------------------------------------------
# JA Showcase 1.0.0 - May, 2007
# ------------------------------------------------------------------------
# Copyright (C) 2004-2007 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
# @license - Copyrighted Commercial Software
# Author: J.O.O.M Solutions Co., Ltd
# Websites:  http://www.joomlart.com -  http://www.joomlancers.com
-------------------------------------------------------------------------*/

class JA_Component_Menu {
	function showComponentMenuBegin($current, $nav, $component) {
		global $mainframe;

		$style = '
		<link rel="stylesheet" href="'.JURI::base().'components/' . $component .'/views/common/assets/styles/style.css" type="text/css" />
		<script language="JavaScript" src="'. JURI::base() .'components/' . $component .'/views/common/assets/styles/jacompmenu.js" type="text/javascript"></script>';

		$mainframe->addCustomHeadTag($style);
		echo '
		<table border="0" cellspacing="0" cellpadding="0" style="text-align: left; width: 100%;">
			<tr>
				<td style="width: 230px; vertical-align: top;">
					<div id="ja-component-menu"><div><div>'; 
		  JA_Component_Menu::showMenu($current, $nav, $component, 1);

		echo '
					</div></div></div>
				</td>
				<td style="">
					<div id="ja-component-frame">';
	}

	function showComponentMenuEnd() {
		echo '
					</div>
				</td>
			</tr>
		</table>';
	}

	function showMenu($current, $nav, $component, $is_root) {
		if ($is_root) $class = " class=\"main\"";
		else $class = " class=\"sub\"";
		echo "<ul>";
		foreach ($nav as $k => $i) {
			if (is_array($i[2])) {
				if ($k == $current) echo "<li$class><span class=\"active\"><img src=\"" . JURI::base()."components/" . $component . "/views/common/assets/styles/icons/" . $i[0] . ".png\" alt=\"\" border=\"0\" />" . $i[1] . "</span>";
				else if ($k == "") echo "<li$class><span><img src=\"". JURI::base()."components/" . $component . "/views/common/assets/styles/icons/" . $i[0] . ".png\" alt=\"\" border=\"0\" />" . $i[1] . "</span>";
				else echo "<li$class><span><img src=\"". JURI::base()."components/" . $component . "/views/common/assets/styles/icons/" . $i[0] . ".png\" alt=\"\" border=\"0\" /><a href=\"$k\">" . $i[1] . "</a></span>";
				
				JA_Component_Menu::showMenu($current, $i[2], $component, 0);
			} else {
				if ($k == $current) echo "<li$class><span class=\"active\"><img src=\"". JURI::base()."components/" . $component . "/views/common/assets/styles/icons/" . $i[0] . ".png\" alt=\"\" border=\"0\" />" . $i[1] . "</span></li>";
				else if ($k == "") echo "<li$class><span><img src=\"". JURI::base()."components/" . $component . "/views/common/assets/styles/icons/" . $i[0] . ".png\" alt=\"\" border=\"0\" />" . $i[1] . "</span></li>";
				else echo "<li$class><span><img src=\"". JURI::base()."components/" . $component . "/views/common/assets/styles/icons/" . $i[0] . ".png\" alt=\"\" border=\"0\" /><a href=$k>" . $i[1] . "</a></span></li>";
			}
		}
		echo "</ul>";
	}
}
?>